// 计算仲裁费用
export function computeFee (money, type) {
  if (type === '特殊收费') {
    return computeSpecialFee(money)
  }
  const acceptanceFee = Math.round(computeAcceptanceFee(money))
  const processingFee = Math.round(computeProcessingFee(acceptanceFee))
  return {
    acceptanceFee, // 受理费
    processingFee // 处理费
  }
}

// 计算受理费
export function computeAcceptanceFee (amount) {
  if (amount <= 1000) {
    return 40
  } else if (amount > 1000 && amount <= 50000) {
    return 40 + (amount - 1000) * 0.04
  } else if (amount > 50000 && amount <= 100000) {
    return 2000 + (amount - 50000) * 0.03
  } else if (amount > 100000 && amount <= 200000) {
    return 3500 + (amount - 100000) * 0.02
  } else if (amount > 200000 && amount <= 500000) {
    return 5500 + (amount - 200000) * 0.01
  } else if (amount > 500000 && amount <= 1000000) {
    return 8500 + (amount - 500000) * 0.005
  } else if (amount > 1000000) {
    return 11000 + (amount - 1000000) * 0.0025
  }
}

// 计算处理费
export function computeProcessingFee (acceptFee) {
  const f = 0.2 * acceptFee
  if (f < 200) {
    return 200
  }
  return f
}

// 计算特殊收费
export function computeSpecialFee (money) {
  let acceptanceFee = 0
  if (money <= 0) {
    return 0
  } else if (money < 10000) {
    acceptanceFee = 50
  } else if (money >= 10000 && money < 100000) {
    acceptanceFee = money * 0.025 - 200
  } else if (money >= 100000 && money < 200000) {
    acceptanceFee = money * 0.02 + 300
  } else if (money >= 200000 && money < 500000) {
    acceptanceFee = money * 0.015 + 1300
  } else if (money >= 500000 && money < 1000000) {
    acceptanceFee = money * 0.01 + 3800
  } else if (money >= 1000000 && money < 2000000) {
    acceptanceFee = money * 0.009 + 4800
  } else if (money >= 2000000 && money < 5000000) {
    acceptanceFee = money * 0.008 + 6800
  } else if (money >= 5000000 && money < 10000000) {
    acceptanceFee = money * 0.007 + 11800
  } else if (money >= 10000000 && money < 20000000) {
    acceptanceFee = money * 0.006 + 21800
  } else {
    acceptanceFee = money * 0.005 + 41800
  }
  return {
    acceptanceFee: Math.round(acceptanceFee), // 受理费
    processingFee: 0 // 处理费
  }
}
